﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using NanjingbeiRailwayStation.Data.ClickHouse.Entities;
using NanjingbeiRailwayStation.Data.ClickHouse.Models;

namespace NanjingbeiRailwayStation.Data.ClickHouse.Services
{
    /// <summary>
    /// 
    /// </summary>
    public class DeviceOwnerService
    {
     
        /// <summary>
        /// 
        /// </summary>
        /// <param name="imei"></param>
        /// <returns></returns>
        public async Task<Entities.DeviceOwner?> GetDeviceOwner(string imei)
        {
            using var db = new NanjingbeiRailwayStation.Data.ClickHouse.Db();

            string sql = string.Format(@"select * from jindujiangong.DeviceOwner
                                        where Imei='{0}'", imei);
            var entity = await db.Database.SqlQueryRaw<DeviceOwner>(sql).FirstOrDefaultAsync();
            return entity;
        }
    }
}
